package 链表题目.反转链表;

import java.util.Stack;

public class Solution {
    public ListNode ReverseList(ListNode head) {
        Stack<Integer> stack = new Stack<>();
        ListNode cur1 = head;
        ListNode cur2 = head;
        while (cur1!=null){
            stack.push(cur1.val);
            cur1 = cur1.next;
        }
        while (!stack.isEmpty()){
            cur2.val = stack.pop();
            cur2 = cur2.next;
        }
        return head;
    }
}
